package com.demo.component;

import com.demo.entity.constants.Constants;
import com.demo.entity.dto.SysSettingDto;

import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component("redisComponent")
public class RedisComponent {

    @Resource
    private RedisUtils redisUtils;



    /**
     * 系统默认获取设置
     * @return
     */
    public SysSettingDto getSysSettingDto() {
        SysSettingDto sysSettingDto = (SysSettingDto) redisUtils.get(Constants.REDIS_KEY_SETTING);
        if (null == sysSettingDto) {
            sysSettingDto = new SysSettingDto();
            redisUtils.set(Constants.REDIS_KEY_SETTING, sysSettingDto);
        }
        return sysSettingDto;
    }

    /**
     * 保存系统设置
     * @param sysSettingDto
     */
    public void saveSetting(SysSettingDto sysSettingDto) {
        redisUtils.set(Constants.REDIS_KEY_SETTING, sysSettingDto);
    }




}

